package com.plm.blogs.utils;

import lombok.Data;

import java.io.Serializable;

/**
 * @author Limi
 * @create 2019-01-11 12:58
 */
@Data
public class ResultMsg implements Serializable {

    private String status;//状态：0失败，1成功
    private String msg;//结果信息
    private String go;//跳转到哪个页面
    private static final ResultMsg okR = new ResultMsg("1", "Ok");
    private static final ResultMsg okRG = new ResultMsg("1", "Ok", "");
    private static final ResultMsg erR = new ResultMsg("0", "Error");
    private static final ResultMsg erRG = new ResultMsg("0", "Error", "");

    private ResultMsg(String status, String msg){
        this.status = status;
        this.msg = msg;
    }

    private ResultMsg(String status, String msg, String go){
        this.status = status;
        this.msg = msg;
        this.go = go;
    }

    public static ResultMsg error(){
        return erR;
    }

    public static ResultMsg error(String msg){
        erR.setMsg(msg);
        return erR;
    }

    public static ResultMsg error(String msg, String go){
        erR.setMsg(msg);
        erR.setGo(go);
        return erR;
    }

    public static ResultMsg ok(){
        return okR;
    }

    public static ResultMsg ok(String msg){
        okR.setMsg(msg);
        return okR;
    }

    public static ResultMsg okGo(String go){
        okR.setGo(go);
        return okR;
    }

    public static ResultMsg ok(String msg, String go){
        okR.setMsg(msg);
        okR.setGo(go);
        return okR;
    }
}
